#ifndef _RAWSOCKET_H_
#define _RAWSOCKET_H_

#include "net/Socket.hpp"
#include "net/SocketImpl.hpp"
#include "net/IPAddress.hpp"
#include "net/SocketAddress.hpp"

NET_NAMESPACE_BEGIN

class CRawSocket : public CSocket
{
public:
	CRawSocket();
	CRawSocket(CIPAddress::Family family, int proto = IPPROTO_RAW);
	CRawSocket(const CSocketAddress& address, bool reuseAddress = false);
	CRawSocket(const CSocket& socket);
	~CRawSocket();
	CRawSocket& operator = (const CSocket& socket);


	void connect(const CSocketAddress& address);
	void bind(const CSocketAddress& address, bool reuseAddress = false);
	int sendBytes(const void* buffer, int length, int flags = 0);
	int receiveBytes(void* buffer, int length, int flags = 0);
	int sendTo(const void* buffer, int length, const CSocketAddress& address, int flags = 0);
	int receiveFrom(void* buffer, int length, CSocketAddress& address, int flags = 0);

	void setBroadcast(bool flag);
	bool getBroadcast() const;

protected:
	CRawSocket(CSocketImpl* pImpl);
};

NET_NAMESPACE_END

#endif
